/*
 * ENUM Discoverer. ENUM Demonstration software, demonstrating the potential of ENUM.
 * 
 * Copyright (C) 2009 SIDN and ISOC.nl
 * 
 * This file is part of ENUM Discoverer.
 *
 * ENUM Discoverer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ENUM Discoverer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ENUM Discoverer.  If not, see <http://www.gnu.org/licenses/>.
 */

package nl.sidn.enumdiscoverer.startup;

import nl.sidn.enumdiscoverer.callhandling.CallBroadcastReceiver;
import nl.sidn.enumdiscoverer.sync.EnumSyncService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Starts {@link CallBroadcastReceiver} and {@link EnumSyncService} on system startup,
 * if they are enabled in preferences.
 * Must be registered in the manifest to receive android.intent.action.BOOT_COMPLETED
 * intents.
 * 
 * @author Grant Patterson (grant.patterson@catalyst.net.nz)
 */
public class BootBroadcastReceiver extends BroadcastReceiver {
	
	@Override
	public void onReceive(Context context, Intent intent) {
		
		if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
			
			StartupHelper.initEnvironment(context);
			
			StartupHelper.initIncallScreen(context);
			
			// schedule the sync service if it is enabled
			StartupHelper.initSyncService(context);
		}
	}
}
